package com.stylefeng.guns.modular.goods.service.impl;

import com.google.common.collect.Lists;
import com.stylefeng.guns.common.SelectValue;
import com.stylefeng.guns.modular.goods.model.Brand;
import com.stylefeng.guns.modular.goods.model.Category;
import com.stylefeng.guns.modular.goods.dao.CategoryMapper;
import com.stylefeng.guns.modular.goods.service.ICategoryService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 分类表 服务实现类
 * </p>
 *
 * @author wuyifie
 * @since 2018-09-05
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements ICategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public List<SelectValue> listOption() {
        List<SelectValue> list = Lists.newArrayList();
        for (Category category : selectList(null)) {
            list.add(new SelectValue(category.getId(),category.getCategoryName()));
        }
        return list;
    }

    @Override
    public void delById(Long categoryId) {
        categoryMapper.deleteById(categoryId);
    }
}
